home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / rpg / crossfir.001 / crossfir~ / eutl / chain-hash / chain-hash.h < prev    next >
C/C++ Source or Header  |  1994-09-19  |  1KB  |  40 lines

  1. #ifndef __chain_hash_h
  2. #define __chain_hash_h
  3.  
  4. #include <errlib.h>
  5. #include <inttypes.h>
  6.  
  7. typedef struct __chain_hash *HashTable;
  8. typedef UM32B (*HashFunction)(register unsigned char *key,register xint len);
  9. typedef void (*DestroyBucketFunc)(unsigned char *key,register xint keylen,
  10.                   unsigned char *data,register xint datalen);
  11. typedef struct __HashStatistics {
  12.   xint bucketsused,nbuckets,nentries;
  13.   xint lookups, comparisons;
  14. } HashStatistics;
  15.  
  16. /* a negative tablesize will pick the smallest internally kept prime bigger 
  17.    than the number specified.  Otherwise, the tablesize should be a prime */
  18.    
  19. HashTable CreateHashTable(xint tablesize,HashFunction hfunc);
  20. void DestroyHashTable(HashTable table,DestroyBucketFunc func);
  21.  
  22. /* Insert will complain if the key already exists */
  23. void HashInsert(HashTable table,void *key,xint keylen,void *data,xint datalen);
  24. void SHashInsert(HashTable table,char *key,void *data,xint datalen);
  25.  
  26. /* Overwrite will overwrite the key/value if it exists, and otherwise
  27.    will perform an insert */
  28. void HashOverwrite(HashTable table,void *key,xint keylen,
  29.            void *data,xint datalen);
  30. void SHashOverwrite(HashTable table,char *key,void *data,xint datalen);
  31.  
  32. void *HashLookup(HashTable table,void *key,xint keylen);
  33. void *SHashLookup(HashTable table,char *key);
  34. HashStatistics *GetStatistics(HashTable table);
  35.  
  36. extern char *chainhash_packagever;
  37. extern char *chainhash_Ebadinsert;
  38. extern char *chainhash_Ebadlookup;
  39. #endif
  40.